<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('库存统计列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>物资编号：</label>
                                <input type="text" name="productId"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:viewstockstatistic:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:viewstockstatistic:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:viewstockstatistic:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
              <!--  <a class="btn btn-warning" onclick="$.table.exportExcel()" >
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div id="div1" style="height: 350px" class="col-sm-8 select-table  table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
            <div id="div2" style="height: 350px" class="col-sm-8 select-table  table-striped">
                <table id="bootstrap-table2" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
       /* var editFlag = [[${@permission.hasPermi('system:viewstockstatistic:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:viewstockstatistic:remove')}]];*/
        var prefix = ctx + "search/viewstockstatistic";

            var options = {
                url: prefix + "/list",

                modalName: "库存统计",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'productId',
                    title: '物资id'
                },
                {
                    field: 'productName',
                    title: '物资名称'
                },
                {
                    field: 'sum',
                    title: '总数'
                }],
                //双击显示子表
                onClickRow: function (t, e) {
                    //alert(t.productId);
                    options2.url = ctx + "search/viewstockstatistic/stockZList?productId=" + t.productId;
                    $('#bootstrap-table2').bootstrapTable("refresh", options2)

                }
            };
       $.table.init(options);
       //子表
       var options2 = {
           url:"",
           search: false,
           showRefresh: true,
           showColumns: true,
           minimumCountColumns: 2,
           clickToSelect: true,//是否启用点击选中行
           // height: $("#div2").height() / 1,
           sortName: "assignNum",
           sortOrder: "desc",
           modalName: "入库单据子表",
           method: 'post',
           striped: true, //是否显示行间隔色
           pagination: true,//显示分页
           sidePagination: "client",
           pageNumber: 1,
           pageSize: 15,
           pageList: [10, 25],
           singleSelect: true,
           columns:
               [{
                   checkbox: true,
               },
                   {
                       field: 'stockId',
                       title: '库存ID'
                   },
                   {
                       field: 'stockMainId',
                       title: '库存ID2',
                       sortable: true
                   },
                   {
                       field: 'productId',
                       title: '物资id',
                       visible: true
                   },

                   // {
                   //     field: 'productGuid',
                   //     title: '物资guid',
                   //     visible: false
                   // },
                   {
                       field: 'quantity',
                       title: '齐套总数',
                       align: 'center',

                   },
                   {
                       field: 'inQuantity',
                       title: '当前入库数',
                       align: 'center',

                   },
                   {
                       field: 'uniform',
                       title: '是否齐套',
                       sortable: true,
                   },
                   {
                       field: 'barcode',
                       title: '母件码',
                       visible: true

                   },
                   {
                       field: 'barcodeDetail',
                       title: '子件码',
                       visible: true

                   },
                   {
                       field: 'outQuantity',
                       title: '出库数',
                       visible: true

                   },
                   {
                       field: 'trayCode',
                       title: '托盘号',
                       visible: true

                   }],
           //双击显示子表
           onClickRow: function (z, e) {
               //alert(z.barcode);
               //options2.url = ctx + "search/viewstockstatistic/stockZList?productId=" + t.productId;
               //$('#bootstrap-table2').bootstrapTable("refresh", options2)
               var url =ctx + "search/viewstockstatistic/selectStock?barcode=" + z.barcode;
               var abc ={
                   width:'100px',
                   height:'700px',
                   title:'物品信息1',
                   url: "search/viewstockstatistic/selectStock?barcode=" + z.barcode,
               }
               $.modal.open("物品信息",url,1500);
           },
           onLoadSuccess(data) {
               switch (data.code) {
                   case  500:
                       options2.url = "";
                       $('#bootstrap-table2').bootstrapTable("removeAll")
                       $.modal.alertWarning("查询出错！");
                       break;
                   default:
                       break;
               }
           },
       }
       $('#bootstrap-table2').bootstrapTable(options2)
    </script>
</body>
</html>